<?php

namespace app\beautiful\controller\admin\setting;

use app\BaseController;
use app\common\model\ShopDetailModel;

class WhiteList extends BaseController
{
    public function show()

    {

        $shop_detail=ShopDetailModel::find($this->request->shopId);

        if(null === $shop_detail){

            $shop_detail = new ShopDetailModel();

            $shop_detail->shop_id=$this->request->shopId;

            $shop_detail->save();

        }

        $detail=[
            'white_list_open'=>$shop_detail !== null ? $shop_detail->white_list_open : 0,
        ];

        return $this->success(['detail'=>$detail]);



    }

    public function save()

    {
        $white_list_open = $this->request->param('white_list_open/d',0);

        if(null === $shop_detail = ShopDetailModel::find($this->request->shopId)){

            $shop_detail=new ShopDetailModel();

            $shop_detail->shop_id=$this->request->shopId;

        }

        $shop_detail->white_list_open=$white_list_open;

        $shop_detail->save();

        return $this->success('设置成功');



    }

}